package de.smarthome.szenario;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import de.smarthome.R;
import de.smarthome.database.DatabaseHandler;

public class NewScenarioActivity extends ListActivity {

	Button saveScenarioButton;
	EditText scenarioName;
	LinearLayout layout;
	DatabaseHandler db;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_scenario);
		db = new DatabaseHandler(this);
		
		saveScenarioButton = (Button)findViewById(R.id.scenarioSaveButton);
		scenarioName   = (EditText)findViewById(R.id.scenarioName);

		saveScenarioButton.setOnClickListener(
	        new View.OnClickListener()
	        {
	            public void onClick(View view)
	            {
	            	String scenarioNameAsString = scenarioName.getText().toString();

	            	db.saveStatusForScenario(scenarioNameAsString);
	            	
	            	Log.v("EditText", scenarioNameAsString);
	            	Toast.makeText(getApplicationContext(), 
                            "SCENARIO '" + scenarioNameAsString + "' SAVED", Toast.LENGTH_LONG).show();
	            	finish();
	            	
	            }
	        });
		
	}


	public void addScenarioItem(){
		View.inflate(this, R.layout.item_scenario, layout);
		scenarioName = (EditText)scenarioName.getText();
	}
	
}
